<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>用户登录</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    html,
    body {
      height: 100%;
    }

    body {
      font-size: 14px;
    }

    .container {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }

    .container>div>form>div {
      margin-top: 20px;
    }
  </style>
</head>

<body>
  <div class="container">
    <h3>{{msg}}</h3>
    <div>
      <form id='frm' action="/admin/login" method="POST" onsubmit="return dopost()">
        <div>
          <label>账号：
            <input type="text" name="username" id="">
            <span></span>
          </label>
        </div>
        <div>
          <label>密码：
            <input type="text" name="password" id="">
            <span></span>
          </label>
        </div>
        <div>
          <button>进入系统</button>
        </div>
      </form>
    </div>
  </div>
  <script>
    let userdom = document.querySelector("input[name='username']")
    let passdom = document.querySelector("input[name='password']")
    function dopost() {
      let username = userdom.value.trim();
      let password = passdom.value.trim();

      if (username != '' && password != '') {
        // 提交
        document.querySelector('button').disabled = true;
        return true;
      }
      if (username == '') userdom.nextSibling.nextSibling.innerHTML = '账号不能为空'
      if (password == '') passdom.nextSibling.nextSibling.innerHTML = '密码不能为空'

      return false;
    }
  </script>
</body>

</html>